import request from "../util/requst.js"
//使用axios api封装发请求必须导入
//例子
// export let funget = () => {
//     return request({
//         url: "/api/userlist/get",
//         method: "GET",
//         params: {
//             name: "xixi"
//         }
//     })
// }
//轮播图请求
export let swaper = () => {
    return request({
        url: "api/banner/list",
        method: "GET",
        params: {}
    })
}


//获取推荐产品列表的数据
export let hotList = (count, limitNum) => {
    return request({
        url: 'api/pro/recommendlist',
        method: 'GET',
        params: {
            count,
            limitNum
        }
    })
}


//产品的分类列表
export let noList = () => {
    return request({
        url: 'api/pro/categorylist',
        method: 'GET',
        params: {}
    })
}



// 产品分类下品牌列表

export let LeiData = (category) => {
    return request({
        url: 'api/pro/categorybrandlist',
        method: 'GET',
        params: {
            category
        }

    })
}

// 获取某分类下某品牌的产品列表

export let ListData = (count, limitNum, category, brand) => {
    return request({
        url: 'api/pro/categorybrandprolist',
        method: 'GET',
        params: {
            count,
            limitNum,
            category,
            brand
        }
    })
}


// 验证手机号码是否被注册过
export let TestZC = (tel) => {
    return request({
        url: 'api/user/docheckphone',
        method: 'POST',
        data: {
            tel
        }
    })
}

//发送短信验证码

export let getSms = (tel) => {
    return request({
        url: 'api/user/dosendmsgcode',
        method: 'POST',
        data: {
            tel
        }
    })
}

//验证短信验证码
export let Sms = (tel, telcode) => {
    return request({
        url: 'api/user/docheckcode',
        method: "POST",
        data: { tel, telcode }
    })
}

// 注册
export let Zhuce = (tel, password) => {
    return request({
        url: 'api/user/dofinishregister',
        method: 'POST',
        data: {
            tel,
            password
        }
    })
}

//账户名/手机号/邮箱 + 密码的登录方式

export let Login = (loginname, password) => {
    return request({
        url: 'api/user/login',
        method: 'POST',
        data: {
            loginname,
            password
        }
    })
}

// 获取用户信息
export let getUser = (userid) => {
    return request({
        url: 'api/user/info',
        method: 'GET',
        params: {
            userid
        }
    })
}

//绑定用户名


export let bangUser = (userid, username) => {
    return request({
        url: 'api/user/bindusername',
        method: 'GET',
        params: {
            userid, username
        }
    })
}








//获取详情

export let DetailData = (proid) => {
    return request({
        url: 'api/pro/detail/' + proid,
        method: 'GET',
        params: {
        }
    })
}

// 热门搜索

export let SearchData = () => {
    return request({
        url: 'api/pro/hotword',
        method: 'GET',
        params: {
        }
    })
}


//搜索列表
export let SortData = (count, limitNum, keyword) => {
    return request({
        url: 'api/pro/search',
        method: 'GET',
        params: {
            count, limitNum, keyword
        }
    })
}


// 加入购物车
export let AddCart = (userid, proid, num) => {
    return request({
        url: 'api/cart/add',
        method: 'POST',
        data: {
            userid, proid, num
        }
    })
}


//删除购物车单条数据
export let DelCart = (cartid) => {
    return request({
        url: 'api/cart/remove',
        method: 'POST',
        data: {
            cartid
        }
    })
}

//查看购物车

export let ClearAllCart = (userid) => {
    return request({
        url: 'api/cart/list',
        method: 'POST',
        data: {
            userid
        }
    })
}

//删除当前用户的购物车数据
export let GetCart = (userid) => {
    return request({
        url: 'api/cart/removeall',
        method: 'POST',
        data: {
            userid
        }
    })
}

//更新购物车数量

export let CountCart = (cartid, num) => {
    return request({
        url: 'api/cart/updatenum',
        method: 'POST',
        data: {
            cartid, num
        }
    })
}



//添加地址

//province 省   city    市  county  区  addressDetail   详细地址
//isDefault 默认地址
export let AddRess = (userid, name, tel, province, city, county, addressDetail, isDefault) => {
    return request({
        url: 'api/address/add',
        method: 'POST',
        data: {
            userid, name, tel, province, city, county, addressDetail, isDefault
        }
    })
}

//查询默认地址
// export let DefaultAddRess = (userid) => {
//     return request({
//         url: 'api/address/defaultAddress',
//         method: 'POST',
//         data: {
//             userid,
//         }
//     })
// }


//更新地址接口
//addressid 地址id
export let UpdateAddRess = (addressid, userid, name, tel, province, city, county, addressDetail, isDefault) => {
    return request({
        url: 'api/address/update',
        method: 'POST',
        data: {
            addressid, userid, name, tel, province, city, county, addressDetail, isDefault
        }
    })
}

//地址列表

export let AddRessList = (userid) => {
    return request({
        url: 'api/address/list',
        method: 'GET',
        params: {
            userid
        }
    })
}

// 删除地址
export let DeleteRess = (addressid) => {
    return request({
        url: 'api/address/delete',
        method: 'POST',
        data: {
            addressid
        }
    })
}